<template>
  <div class="login">
    <el-form
      :model="ruleForm"
      status-icon
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
    <h1>登录</h1>
      <el-form-item prop="username">
        <el-input
          type="text"
          v-model="ruleForm.username"
          autocomplete="off"
          placeholder="请输入用户名"
        ></el-input>
      </el-form-item>
      <el-form-item prop="password">
        <el-input
          type="password"
          v-model="ruleForm.password"
          autocomplete="off"
          placeholder="请输入密码"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="login()"
          >登录</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {mapGetters,mapActions} from 'vuex'
export default {
  computed:{
    ...mapGetters({
      ruleForm:'login/ruleForm',
      rules:'login/rules'
    })
  },
  methods: {
    ...mapActions({
      submitForm:'login/submitForm'
    }),
    login(){
      this.submitForm(this)
    }
  }
};
</script>

<style scoped>
.login{
    width: 100vw;
    height: 100vh;
    background: linear-gradient(to right,#563443,#303D60);
    display: flex;
    justify-content: center;
    align-items: center;
}
.el-form{
    width: 300px;
    background-color: white;
    border-radius: 10px;
    padding: 30px 60px;
}
.el-form h1{
    text-align: center;
    margin-bottom: 20px;
    font-weight: bold;
    font-size: 26px;
}
::v-deep .el-form-item__content{
margin-left: 0 !important;
}
.el-button--primary {
width: 100%;
}
</style>